<html>

	<head>
		<title>视频列表</title>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">

		<link href="../../css/skin/default/style.css" rel="stylesheet" type="text/css" />
		<link href="../../css/dialog.css" rel="stylesheet">
		<link href="../../js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />

		<script src="../../js/lib/jquery/jquery-1.10.2.min.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>

		<script src="../../js/lib/ligerUI/js/plugins/ligerPopupEdit.js"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerRadio.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerMenu.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
		<script type="text/javascript" src='../../js/JScripts/plupload/js/plupload.full.min.js'></script>
		<script src="../../js/lib/jquery.form.js" type="text/javascript"></script>
		<script src="../../js/lib/json2.js" type="text/javascript"></script>
		<script src="../../js/dialog.js"></script>
		<script src="../../js/JS/layout.js"></script>
		<script src="../../js/constants.js" type="text/javascript"></script>
		<script src="../../js/api.js" type="text/javascript"></script>

		<script type="text/javascript">
			var manager;
			$(document).hover(parent.hindMenu);

			var Ftypeid = $api.getparastr("ftypeid");
			var photoUrl = BaseUrl + "Photo?token=" + $api.getStorage("token") + "&Ftypeid=" + Ftypeid;

			$(function() {
				$("form").ligerForm();
				initView();

			});

			function initView() {
				var url = photoUrl + "&key=";
				manager = $("#maingrid").ligerGrid({
					columns: [{
							display: '图片',
							name: 'Fpath',
							align: 'left',
							minWidth: 220,
							render: function(rowdata, rowindex, value) {
								console.log(rowdata.Fpath);
								return '<img style="height:100px;"  src="' + rowdata.Fpath + '" />';

							}
						},
						{
							display: '文件名',
							name: 'Fname',
							align: 'left',
							minWidth: 220
						},
						{
							display: '创建日期',
							isSort: true,
							name: 'Fdate',
							type: 'date',
							width: 200,
							align: 'center'
						},
						{
							display: '图片大小',
							name: 'Fsize',
							align: 'left',
							width: 200,
							render: function(rowdata, rowindex, value) {
								if(rowdata.Fsize < 1024) return rowdata.Fsize + "B";
								else if(rowdata.Fsize < 1024 * 1024)
									return(rowdata.Fsize / 1024).toFixed(2) + "KB";
								else
									return(rowdata.Fsize / 1024 / 1024).toFixed(2) + "M";
							}
						}
					],
					dataAction: 'local',
					url: url,
					checkbox: true,
					method: 'get',
					width: '99.5%',
					rowHeight: 110,
					pageSize: 10,
					usePager: true
				});

			}

			function doSearch(high) {
				var key = $("#txtKeywords").val();
				var url = pageUrl + "&key=" + key;
				manager.GetDataByURL(url);
			}

			function f_reload() {
				manager.loadData(true);
			}

			function move() {
				parent.openCommWindow2('vcommon/sys_config/PhotoDialog.html',
					"相册", 400, 320,
					function(res) {
						var rows = manager.getSelectedRows();

						var ids = "";
						for(var i in rows) {
							var row = rows[i];
							ids += row.Fid + ",";
						}
						ids = ids.substr(0, ids.length - 1); 
						var pararm = {
							"Ftypeid": Ftypeid,
							"Fids": ids,
							"Fntypeid": res.Fid
						}
						var url = BaseUrl + "Photo?token=" + $api.getStorage("token")+ "&action=move";
						

						$api.ajax2(url, pararm, function(data) {
							f_reload();
						});
					});

			}

			function del() {
				var rows = manager.getSelectedRows();
				if(rows) {
					$.ligerDialog.confirm("图片删除后不能恢复，\n您确定要移除？", function(yes) {
						if(yes) {
							var ids = "";
							for(var i in rows) {
								var row = rows[i];
								ids += row.Fid + ",";
							}
							ids = ids.substr(0, ids.length - 1); 
							var pararm = {
								"Ftypeid": Ftypeid,
								"Fids": ids
							}
							var url = BaseUrl + "Photo?token=" + $api.getStorage("token")+ "&action=del";
							$api.ajax2(url, pararm, function(data) {
								f_reload();
							});
						}
					})
				} else
					$.ligerDialog.warn("请选择需要删除的图片！");

			}

			function ret() {
				window.history.go(-1);
			}
		</script>

	</head>

	<body class="mainbody">
		<form id="form1" onsubmit="return false">
			<div class="div-alarm">图片删除后，服务器将保留15天图片缓存，15天后图片将不能恢复</div>
			<div class="toolbar-wrap">
				<div  class="toolbar">
					<div class="l-list">
						<ul id="icon-list" class="icon-list">
							<li>
								<a class='ret' onclick='ret();'><i></i><span>返回</span></a>
							</li>
							<li>
								<a class='move' onclick='move();'><i></i><span>移动</span></a>
							</li>
							<li>
								<a class='del' onclick='del();'><i></i><span>删除</span></a>
							</li>
						</ul>
					</div>
					<div class="r-list">
						<input type="text" ID="txtKeywords" placeholder='图片名称' class="keyword" />
						<a class='btn-search' onclick='doSearch(false);' style="margin-right:10px;">搜索</a>

					</div>
				</div>
			</div>

			<div id="maingrid" style="margin: 0px;background:#fff;"></div>

		</form>

	</body>

</html>